<extend name="Layout/ins_popup" />
<block name="content">

	<input type="hidden" name="ajax" id="ajax" value="1">
	<div class="popup-frame">
		<div class="popup-header">
			<div class="pull-left">
				<h1>新增菜单</h1>
			</div>
			<div class="pull-right">
				<a id="btn_save" class="btn" >确定</a>
				<a id="btn_close" class="btn btn-cancel">关闭</a>
			</div>
		</div>
		<div class="popup-body">
			<div class="popup-body-scroll">
				<div class="popup-content">
					<form id="form_data" name="form_data" method="post" class="weixin">
						<input type="hidden" name="ajax" id="ajax" value="1">
						<input type="hidden" name="opmode" id="opmode" value="add">
						<div class="frame">
							<div class="bit-1">
								<div class="layui-form-item">
									<label class="layui-form-label" for="name">菜单名称*：</label>
									<div class="layui-input-block">
										<input class="layui-input" type="text" id="name" name="name" check="required" info="请输入菜单名称">
									</div>
								</div>
							</div>
							<div class="bit-1">
								<div class="layui-form-item">
									<label class="layui-form-label" for="val">事件选择*：</label>
									<div class="layui-input-block x-select">
										<select class=" layui-input" name="type"id="type">
											<option value="click">点击推事件</option>
											<option value="view">跳转URL</option>
											<option value="scancode_push">扫码推事件</option>
											<option value="scancode_waitmsg">扫码推事件且弹出“消息接收中”提示框</option>
											<option value="pic_sysphoto">弹出系统拍照发图</option>
											<option value="pic_photo_or_album">弹出拍照或者相册发图</option>
											<option value="location_select">弹出地理位置选择器</option>
											<option value="media_id">下发消息（除文本消息）</option>
											<option value="view_limited">跳转图文消息URL</option>
										</select>
										<p>
											注：需要进行链接的事件为view事件
										</p>
									</div>
								</div>
							</div>
							<div class="bit-1">
								<div class="layui-form-item">
									<label class="layui-form-label" for="url">URL*：</label>
									<div class="layui-input-block">
										<input class="layui-input" type="text" id="url" name="url"  >
										<p>
											示例：index.php?m=&c=Task&a=folder&fid=all
										</p>
									</div>
								</div>
							</div>
							<div class="bit-1">
								<div class="layui-form-item">
									<label class="layui-form-label" for="key">Key*：</label>
									<div class="layui-input-block">
										<input class="layui-input" type="text" id="key" name="key" >
										<p>
											注：每个菜单需要有单独的key
										</p>
									</div>
								</div>
							</div>
							<div class="bit-1">
								<div class="layui-form-item">
									<label class="layui-form-label" for="pid_name">父级*：</label>
									<div class="layui-input-block">
										<div class="input-group">
											<input name="pid_name" class="layui-input" id="pid_name" type="text" readonly="readonly" info="请选择父级" check="required"/>
											<input name="pid" id="pid" type="hidden" info="请选择父级" check="required" />
											<span class="add-on" id="btn_select_pid" > 选择 </span>
										</div>
									</div>
								</div>
							</div>
							<div class="bit-1">
								<div class="layui-form-item">
									<label class="layui-form-label" for="sort">排序：</label>
									<div class="layui-input-block col-10">
										<input class="layui-input" type="text" id="sort" name="sort" >
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var $ = layui.jquery;
			$pid = $("#id", parent.document).val();
			$("#pid").val($pid);

			//保存后关闭
			$('#btn_save').on('click', function() {
				send_form('form_data', '{:U("add_weixin_menu")}', '', function(ret) {
					if (ret.status == 1) {
						layer.msg(ret.info, {
							time : 1200
						}, function() {
							parent.location.reload(true);
							parent.layer.close(index);
						});
					} else {
						layer.msg(ret.info);
						return false;
					};
				});
			});

			//关闭iframe
			$('#btn_close').click(function() {
				parent.layer.close(index);
			});

			$('#btn_select_pid').on('click', function() {
				winopen("{:U('winpop_weixin')}", 560, 470);
			});
		});

	</script>

</block>